<?php


namespace app\web\model;

use \app\common\model\web\Organization as OrganizationModel;

class Organization extends OrganizationModel
{

    /** @var int 组织机构 0内部机构 */
    public const ORG_TYPE_INSIDE = 0;
    /** @var int 组织机构 1外部门店 */
    public const ORG_TYPE_OUTSIDE = 1;
    /** @var int 组织机构 2仓库 */
    public const ORG_TYPE_WAREHOUSE = 2;

    /**
     * 组织机构类型名
     * @var string[]
     */
    public static $ORG_TYPE_NAME = [
        self::ORG_TYPE_INSIDE => "内部机构",
        self::ORG_TYPE_OUTSIDE => "外部门店",
        self::ORG_TYPE_WAREHOUSE => "仓库",
    ];

    public function getList($where, $field = '*', $order = 'create_time desc')
    {
        return parent::getList($where, $field, $order); // TODO: Change the autogenerated stub
    }

    /**
     * 根据条件查询
     * @param string $clientIds
     * @param array $fields
     * @param array $where
     * @return \think\Collection
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function getListByWhere($where = [], $clientIds = "", $fields = [])
    {
        $model = new OrganizationModel();
        return json_decode($model->where($where)->whereIn('org_id', $clientIds)->field($fields)->select(), true);
    }

}